<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\erp\model;

use think\Model;

/**
 * 采购/调拨 入库申请
 * @package app\erp\model
 */
class ErpGoodsWarehousing extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'xm_erp_goods_warehousing';
	
	/**
     * 添加数据
     * @param order_id		int		采购/调拨 单ID
     * @param type 		    int     入库方式 1采购 2调拨
     * @param handled_by 	string  经办人
     * @param remark 		string  备注
     * @param code 			string  采购/调拨 单code
     * @author shiqiang
     * @return array_out(code, message, (int)id)
     */
	public function addData($type, $order_id, $handled_by, $remark, $code){
		$data['type']   	= $type;
        $data['order_id']  	= $order_id;
        $data['handled_by'] = $handled_by;
        $data['remark']		= $remark;
        $data['code']       = $code;
        $res = $this -> isUpdate(false) ->data($data, true) -> save();
        if($res){
            return array_out(200, 'success', $this -> id);
        }else{
            return array_out(-1001, 'error');
        }
	}
	
	/**
     * 编辑数据
     * @param handled_by 	string  经办人
     * @param remark 		string  备注
     * @author shiqiang
     * @return array_out(code, message, (int)id)
     */
	public function editData($id, $handled_by, $remark){
        $data['rk_handled_by'] = $handled_by;
        $data['rk_remark']		= $remark;
		
		$map = [];
		$map['id']			= $id;
		
        $res = $this ->update($data, $map);
        if($res){
            return array_out(200, 'success');
        }else{
            return array_out(-1001, 'error');
        }
	}
}
